// -----------------------------------------------------------------------------
// File Name    : portconfig.h
// Title        : Port Manipulation Module
// Author       : Seeseawe - Copyright (C) 2008
// Created      : 2008-11-12
// Version      : 0.1
// Target MCU   : LPC2132
// Editor Tabs  : 4
// Editor Line  : 80 chars/line
// -----------------------------------------------------------------------------
// Version History:
/*
    >>>2008-11-12: V0.1 is released.
*/
// OverView:
/* 
	Usage:
	SetPin(P0_1, 0);	// Set P0_1 as its first function(i.e. GPIO)
	AsOutput(P0_1);		// Set P0_1 as output
	PinSetHigh(P0_1);	// Set P0_1 to High-level
	PinSetLow(P0_1);	// Set P0_1 to Low-level
	PinToggle(P0_1);	// If P0_1 is High, set it Low, vice-versa
	stateof(P0_1);		// return the pin state of P0_1
*/

#ifndef __PORTCONFIG_H__
#define __PORTCONFIG_H__

typedef enum
{
	PA0,
	PA1,
	PA2,
	PA3,
	PA4,
	PA5,
	PA6,
	PA7,
	PA8,
	PA9,
	PA10,
	PA11,
	PA12,
	PA13,
	PA14,
	PA15,
	
	PB0,
	PB1,
	PB2,
	PB3,
	PB4,
	PB5,
	PB6,
	PB7,
	PB8,
	PB9,
	PB10,
	PB11,
	PB12,
	PB13,
	PB14,
	PB15,
	
	PC0,
	PC1,
	PC2,
	PC3,
	PC4,
	PC5,
	PC6,
	PC7,
	PC8,
	PC9,
	PC10,
	PC11,
	PC12,
	PC13,
	PC14,
	PC15,
	
	PD0,
	PD1,
	PD2,
	PD3,
	PD4,
	PD5,
	PD6,
	PD7,
	PD8,
	PD9,
	PD10,
	PD11,
	PD12,
	PD13,
	PD14,
	PD15
}IO_def;


// --------------------------- function prototypes ----------------------------
/* ----------------------------------------------------------------------------
   name: SetPin
   function: Set a pin to its specific function
   inputs: PinName(PA0 ~ PA15, PB0 ~ PB15),
		   GPIO_mode(GPIO_Mode_AIN = 0x0,
					  GPIO_Mode_IN_FLOATING = 0x04,
					  GPIO_Mode_IPD = 0x28,
					  GPIO_Mode_IPU = 0x48,
					  GPIO_Mode_Out_OD = 0x14,
					  GPIO_Mode_Out_PP = 0x10,
					  GPIO_Mode_AF_OD = 0x1C,
					  GPIO_Mode_AF_PP = 0x18
   return: none
---------------------------------------------------------------------------- */
void SetPin(IO_def PinName, GPIOMode_TypeDef GPIO_mode);
/* ----------------------------------------------------------------------------
   name: AsInput
   function: Set a GPIO pin as input
   inputs: PinName
   return: none
---------------------------------------------------------------------------- */
void AsInput(IO_def PinName);
/* ----------------------------------------------------------------------------
   name: AsOutput
   function: Set a GPIO pin as output
   inputs: PinName
   return: none
---------------------------------------------------------------------------- */
void AsOutput(IO_def PinName);
/* ----------------------------------------------------------------------------
   name: PinSetHigh
   function: Set a GPIO pin to high-level
   inputs: PinName
   return: none
---------------------------------------------------------------------------- */
void PinSetHigh(IO_def PinName);
/* ----------------------------------------------------------------------------
   name: PinSetLow
   function: Set a GPIO pin to low-level
   inputs: PinName
   return: none
---------------------------------------------------------------------------- */
void PinSetLow(IO_def PinName);
/* ----------------------------------------------------------------------------
   name: PinToggle
   function: Toggle the state of PinName
   inputs: PinName
   return: none
---------------------------------------------------------------------------- */
void PinToggle(IO_def PinName);
/* ----------------------------------------------------------------------------
   name: StateOf
   function: Get the pin state of PinName
   inputs: PinName
   return: state
---------------------------------------------------------------------------- */
u8 StateofOutputPin(IO_def PinName);

u8 StateofInputPin(IO_def PinName);
// ----------------------------------------------------------------------------

#endif

